<template>
  <div class="course-upload">
    <h1>课程上传</h1>
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="课程名称">
        <el-input v-model="form.courseName"></el-input>
      </el-form-item>
      <el-form-item label="课程描述">
        <el-input type="textarea" v-model="form.description"></el-input>
      </el-form-item>
      <el-form-item label="课程文件">
        <el-upload
          action="http://localhost:3000/upload"
          :on-success="handleSuccess"
          :file-list="fileList">
          <el-button size="small" type="primary">点击上传</el-button>
        </el-upload>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      form: {
        courseName: '',
        description: ''
      },
      fileList: []
    };
  },
  methods: {
    onSubmit() {
      // 这里可以添加提交表单的逻辑
      console.log(this.form);
    },
    handleSuccess(response, file, fileList) {
      console.log(response, file, fileList);
      this.fileList = fileList;
    }
  }
};
</script>
 
<style scoped>
.course-upload {
  padding: 20px;
}
</style>
